class Solution {
    public String removeDuplicates(String s) {
        StringBuffer ret = new StringBuffer();
        char[] ss=s.toCharArray();
        for(char ch:ss){
            if(ret.length()>0&&ret.charAt(ret.length()-1)==ch){
                ret.deleteCharAt(ret.length()-1);
            }else{
                ret.append(ch);
            }
        }
        return ret.toString();
    }
}